<?php
/**
 * App for managing contacts
 * 
 * Template for contact edit
 * 
 * @category Abovo
 * 
 * @package Abovo_App_Crm
 * 
 * @subpackage Abovo_App_Crm_Contacts
 * 
 * @license http://opensource.org/licenses/gpl-license.php GPL
 * 
 * @author Antti Holvikari <anttih@gmail.com>
 */
?>
<?php echo $this->script('Abovo/scripts/companies.js') ?>
<?php $this->JsPrototype()->event->observe('#company', 'keyup', 'function() {' .
    // new ajax request
    $this->JsPrototype()->ajax->request(
        // location
        $this->action('crm/companies/ajaxCompanies') . "/' + $('company').value + '",
        array(
            'method'     => 'GET',
            'onSuccess'  => "function(response) { populateCompanies(response, 'contact-companies_id'); }",
            '_deQuote'   => array('onSuccess'),
        )
    )
. '}') ?>

<?php echo $this->form()
                ->setStatus($this->contact_form->getStatus())
                ->addFeedback($this->contact_form->feedback)
                ->addElement($this->contact_form->elements['contact[firstname]'])
                ->addElement($this->contact_form->elements['contact[lastname]'])
                ->addElement($this->contact_form->elements['contact[gender]'])
                ->addElement($this->contact_form->elements['contact[email]'])
                ->addElement($this->contact_form->elements['contact[tel]'])
                ->addElement($this->contact_form->elements['contact[adr]'])
                ->addElement($this->contact_form->elements['contact[postal_code]'])
                ->addElement($this->contact_form->elements['contact[city]'])
                ->addElement($this->contact_form->elements['contact[country]'])
                ->beginGroup('Company')
                ->addElement(array(
                    'type'  => 'text',
                    'name'  => 'company',
                    'label' => 'Company',
                    'attribs' => array(
                        'size' => 10,
                    )
                ))
                ->addElement($this->contact_form->elements['contact[companies_id]'])
                ->endGroup()
                ->addElement(array(
                    'type' => 'submit',
                    'name' => 'process',
                    'value' => $this->getText('PROCESS_SAVE'),
                ))
                ->fetch()
?>